package me.yushuai.wukong.base.convertor;

import me.yushuai.wukong.base.api.dto.*;
import me.yushuai.wukong.base.api.vo.ConfGroupVO;
import me.yushuai.wukong.base.api.vo.ConfVO;
import me.yushuai.wukong.base.entity.Conf;
import me.yushuai.wukong.base.entity.ConfGroup;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

import java.util.List;

/**
 * @author zhoushuai@189.cn
 * @since 2022-12-12
 */
@Mapper(componentModel = "spring")
public interface ConfConvertor {

    @Mapping(target = "showSequence", ignore = true)
    @Mapping(target = "itemNameE", ignore = true)
    @Mapping(target = "itemNameC", ignore = true)
    ConfDTO mapToConfDto(Conf conf);

    @Mapping(target = "udf3", ignore = true)
    @Mapping(target = "udf2", ignore = true)
    @Mapping(target = "udf1", ignore = true)
    @Mapping(target = "modifyTime", ignore = true)
    @Mapping(target = "modifyBy", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "confNameE", ignore = true)
    @Mapping(target = "confNameC", ignore = true)
    @Mapping(target = "bizId", ignore = true)
    void updateConf(UpdateConfValueDTO dto, @MappingTarget Conf conf);

    @Mapping(target = "modifyTime", ignore = true)
    @Mapping(target = "modifyBy", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    void updateConf(UpdateConfDefDTO dto, @MappingTarget Conf conf);

    List<ConfDTO> mapToConfDtoList(List<Conf> content);

    @Mapping(target = "modifyTime", ignore = true)
    @Mapping(target = "modifyBy", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    Conf mapToConf(CreateConfDTO dto);

    @Mapping(target = "modifyTime", ignore = true)
    @Mapping(target = "modifyBy", ignore = true)
    @Mapping(target = "modified", ignore = true)
    @Mapping(target = "lastSequence", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    ConfGroup mapToConfGroup(CreateConfGroupDTO dto);

    void updateToConfGroup(UpdateConfGroupDTO dto, @MappingTarget ConfGroup confGroup);

    ConfGroupDTO mapToConfGroupDto(ConfGroup confGroup);

    List<ConfGroupDTO> mapToConfGroupDtoList(List<ConfGroup> content);

    ConfVO mapToConfVo(ConfDTO conf);

    ConfGroupVO mapToConfGroupVo(ConfGroupDTO confGroup);

    List<ConfGroupVO> mapToConfGroupVoList(List<ConfGroupDTO> confGroups);
}
